import JSEncrypt from 'jsencrypt'

let priKey =
	'-----BEGIN RSA PRIVATE KEY-----MIICXQIBAAKBgQDvupVIIoSGBwdLXqP/ox0YYr1pj7ZmadC7i0mujqzIjpBh/NCJmZWtb4rmZyN18PPcctxIbyndJQ//BrUnFc4v0F4fjciHBuwSBAtaMBjoyj2CBiijHK6H96+cHv+AiudD0Vf3Ij0T7BaLZJZ/Ss3M25mRuT5cYN09M8Bt34Dv2wIDAQABAoGAVJQNqx+Shf7g0fSYA882qq3biezMO6HFpQVlf5KS30d9JTUfFgz7w+8AoH1vA2N5hiN4GI4vxPgYhq+FJj8JOSKAcmaGYnPKUd41yI/07tHMxNuXngJW0AyjhFFloEwp620VZGMzdPqkUMG5JvIViYoXc5yb1bE55l0TOUHUK/ECQQD9BYx4KqlNs9VKdrBla79iqjlgAff8nK542g/pIeKTcin/ARQRxVue/ABHyNnaJY+Ji7fpRACg3u2ECklur1DlAkEA8oz6X2l2xt+lK2bXCJhQ8dI68DGAQZBIwAHNQfTkppZXuTg/EErPo6XgXT3cletQ6+rvF3Dd2lk8loRQ5JzxvwJAdUIxCy+aLqx82HmQ3i/FDlCdLmU7LBLguJk2bnCJtJNf6xHw3xt7jn5zEtF+RJ7Lmo7puG0PbX5izKKHzYfqEQJBALTZGuHDQBW+sWewEUtOTqRP7TQkpI2+KBBKB6JTF52CYbwvzQ23yiQpzSWYt31s7HRLQqRGupRQjxVnaO1ce/8CQQCy65L/c+kqTF3zqrnoaKlScz6D877fsR1MQO3OJdCPkJdKTaGVrtKMazBBp0CN9Z98SJxvqIFizpesQnb+Daq2-----END RSA PRIVATE KEY-----'
const pubKey ='-----BEGIN PUBLIC KEY-----'+
	'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLnzeteKs4Ah2or350vLfR5i/J' +
	'aocK/cnOgQqtDIb0izD/3h0PmT+Mdte28l/laHPTpAAnZy4pwuJsLnf9IecK2/d6' +
	'+ErRQhaJSmE5jT4DuPCHBgEnk+3AHNYic6nBrTqe/JBvQ9m4k3aUILdOwayCzp7X' +
	'F//JGI6TFZJgCmZFvQIDAQAB'+'-----END PUBLIC KEY-----'



let RSA = {
	//使用公钥加密

	jiami(str) {
		let encrypt = new JSEncrypt();
		encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7xjt5yO2YKztq337zXgHIqj7sGV1fnKs07JMrJKxAS/sXAl9HPQQ9j54h2U2AmYvakWqt0BxlHlyoJJ+unttLDhRUDkvj7eE7vT8fcRM+ZfTo2bU8rvMHi3s9GfEG7K60vvkL/K47x9zyMLN2ujEr0yDbJpGgTj79DvO7CkZBKwIDAQAB');
		let encrypted = encrypt.encrypt(str);
		// console.log('加密后数据:%o', encrypted);
		return encrypted
		

	},
	jiemi(str) {
		//使用私钥解密
		let decrypt = new JSEncrypt();
		decrypt.setPrivateKey(priKey);
		let uncrypted = decrypt.decrypt(str);
		return uncrypted;
		console.log('解密后数据:%o', uncrypted); // 张三

	}
}
export default RSA;
